var t = require("../../../../@babel/runtime/helpers/defineProperty");

Component({
    properties: {
        levelList: {
            type: [ String, Array, Object ],
            value: []
        },
        widgetsInfo: {
            type: [ String, Number, Object ],
            value: {}
        }
    },
    data: {
        level_discount_type: !0,
        discount_method: 1
    },
    lifetimes: {
        attached: function() {
            this.getDataInfo();
        }
    },
    methods: {
        changeType: function(e) {
            var i = e.currentTarget.dataset.name;
            this.setData(t({}, i, e.detail));
        },
        changeText: function(t) {
            var e = t.currentTarget.dataset.index, i = t.detail;
            this.data.levelList[e].discount_value = i;
        },
        filertMap: function() {
            var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [], e = t.map(function(t) {
                return {
                    level_id: t.id,
                    discount_value: t.discount_value
                };
            });
            return e;
        },
        validatorData: function() {
            return {
                level_discount_type: this.data.level_discount_type ? 1 : 0,
                discount_method: this.data.discount_method,
                discount_value: this.filertMap(this.data.levelList)
            };
        },
        getDataInfo: function() {
            if (this.data.widgetsInfo && this.data.widgetsInfo.discount) {
                var t = this.data.widgetsInfo.discount, e = t.level_discount_type, i = t.discount_method, a = {};
                a.level_discount_type = Boolean(e), a.discount_method = i, this.setData(a);
            }
        }
    }
});